﻿using System;
using System.Configuration;
using mojoPortal.Net;
using mojoPortal.Web;
using Resources;
using mojoPortal.Web.Framework;
using System.Collections;
using mojoPortal.Business;
using ud_gSDMS.Code_Service;
using mojoPortal.Business.WebHelpers;
using System.IO;
using Brettle.Web.NeatUpload;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.Web.UI;
namespace ud_gSDMS.Member
{
    public partial class UpdateCBInfo : mojoBasePage
    {
        private int pageId = -1;
        private int moduleId = -1;
        private string id;
        private SiteUser _siteUser;
        protected String cacheDependencyKey;
        DBQLNS _respository=new DBQLNS();
        
        void Page_Load(object sender, EventArgs e)
        {
            _siteUser = SiteUtils.GetCurrentSiteUser();
            if (_siteUser == null)
            {
                WebUtils.SetupRedirect(this, SiteRoot + "/AccessDenied.aspx");
            }

            if (!Page.IsPostBack)
            {
                PopulateLabels();
                PopulateControls();
            }
        }
        private void PopulateLabels()
        {
            CBTest child1 = new CBTest("1", "Hoàng Văn Kiếm", "", "10/08/1950", "LGHS", "15.109", "6", "8.00", "BC", "- -", "Trưởng BM", "Tiến sĩ khoa học", "GS",
                "TSKH", "Giáo sư, Tiến sĩ khoa học", "18", "Ban Giám Hiệu", "18", "Ban Giám Hiệu", "", "112-đường số 1, xã Bình Hưng", "kiemhv@uit.edu.vn", "180", "80%");
            CBTest child2 = new CBTest("2", "Trần Vĩnh Phước", "", "24/08/1953", "LGHS", "15.110", "7", "6.44", "BC", "- -", "P.Hiệu Trưởng, Trưởng BM", "Tiến sĩ", "PGS",
               "TS", "Phó Giáo Sư, Tiến sĩ", "01", "Ban Giám Hiệu", "20", "Ban Giám Hiệu", "0913805972", "145 Ngô Quyền, Q.5", "phuoctv@uit.edu.vn", "160", "75%");
            CBTest child3 = new CBTest("3", "Dương Tôn Đảm", "", "15/06/1952", "LGHS", "15.110", "8", "6.78", "BC", "- -", "P.Hiệu Trưởng, Trưởng BM", "Tiến sĩ", "GVC",
               "TS", "Giảng viên chính, Tiến sĩ", "01", "Ban Giám Hiệu", "33", "Ban Giám Hiệu", "", "", "damdt@uit.edu.vn", "160", "75%");
            List<CBTest> lst = new List<CBTest>();
            lst.Add(child1);
            lst.Add(child2);
            lst.Add(child3);
            Session["Cb"] = lst;
        }
        private void BindData()
        {
            gvChildInfo.DataSource = Session["Cb"];
            gvChildInfo.DataBind();
        }

        private void PopulateControls()
        {
            BindData();
        }
        #region OnInit

        protected override void OnPreInit(EventArgs e)
        {
            AllowSkinOverride = true;
            base.OnPreInit(e);
            Load += Page_Load;
        }

        protected override void OnInit(EventArgs e)
        {
            LoadParams();
            LoadPanels();
            base.OnInit(e);
            SuppressPageMenu();
        }

        private void LoadParams()
        {
            pageId = WebUtils.ParseInt32FromQueryString("pageid", pageId);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", true, moduleId);
            id = WebUtils.ParseStringFromQueryString("id", id);
            cacheDependencyKey = "Module-" + moduleId.ToInvariantString();
        }

        private void LoadPanels()
        {
            bool showLeftColumnAdmin = ConfigHelper.GetBoolProperty("ShowLeftColumnAdmin", false);
            bool showRightColumnAdmin = ConfigHelper.GetBoolProperty("ShowRightColumnAdmin", false);
            bool showTopColumnAdmin = ConfigHelper.GetBoolProperty("ShowTopColumnAdmin", false);
            bool showBottomColumnAdmin = ConfigHelper.GetBoolProperty("ShowBottomColumnAdmin", false);
            int showCenterColumnAdmin = ConfigHelper.GetIntProperty("ShowCenterColumnAdmin", 0);
            LoadSideContent(showLeftColumnAdmin, showRightColumnAdmin, showTopColumnAdmin, showBottomColumnAdmin, showCenterColumnAdmin);
        }
        #endregion

        protected void gvChildInfo_RowEditing(object sender, GridViewEditEventArgs e)
        {
            gvChildInfo.EditIndex = e.NewEditIndex;
            BindData();
        }

        protected void gvChildInfo_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            gvChildInfo.EditIndex = -1;
            BindData();
        }

        protected void gvChildInfo_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            List<CBTest> l = (List<CBTest>)Session["Cb"];
            TextBox txt_hoten = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt1");
            TextBox txt_nu = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt2");
            TextBox txt_ngaysinh = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt3");
            TextBox txt_coluong = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt4");
            TextBox txt_ngach = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt5");
            TextBox txt_bac = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt6");
            TextBox txt_hslg = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt7");
            TextBox txt_loai = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt8");
            TextBox txt_ngaytgct = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt9");
            TextBox txt_chucvu = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt10");
            TextBox txt_hocvi = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt11");
            TextBox txt_mscd = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt12");
            TextBox txt_mstd = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt13");
            TextBox txt_huongdm = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt14");
            TextBox txt_msdv = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt15");
            TextBox txt_tendv = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt16");
            TextBox txt_khoa = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt17");
            TextBox txt_tenkhoa = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt18");
            TextBox txt_dienthoai = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt19");
            TextBox txt_diachi = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt20");
            TextBox txt_email = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt21");
            TextBox txt_cttc = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt22");
            TextBox txt_tldg = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt23");
            string tam = l[e.RowIndex].ID;
            CBTest newreward = new CBTest(tam, txt_hoten.Text, txt_nu.Text, txt_ngaysinh.Text, txt_coluong.Text, txt_ngach.Text, txt_bac.Text, txt_hslg.Text, txt_loai.Text, txt_ngaytgct.Text, txt_chucvu.Text, txt_hocvi.Text, txt_mscd.Text, txt_mstd.Text, txt_huongdm.Text, txt_msdv.Text, txt_tendv.Text, txt_khoa.Text, txt_tenkhoa.Text, txt_dienthoai.Text, txt_diachi.Text, txt_email.Text, txt_cttc.Text, txt_tldg.Text);
            l[e.RowIndex] = newreward;
            gvChildInfo.EditIndex = -1;
            BindData();
        }

        protected void gvChildInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            List<CBTest> l = (List<CBTest>)Session["Cb"];
            l.RemoveAt(e.RowIndex);
            BindData();
        }
    }

    public class CBTest
    {
        public string ID { get; set; }
        public string HoTen {get ; set;}
        public string Nu { get; set; }
        public string NgaySinh { get; set; }
        public string CoLuong { get; set; }
        public string Ngach { get; set; }
        public string Bac { get; set; }
        public string HSLg { get; set; }
        public string Loai { get; set; }
        public string NgayTGCT { get; set; }
        public string ChucVu { get; set; }
        public string HocVi { get; set; }
        public string MSCD { get; set; }
        public string MSTD { get; set; }
        public string HuongDM { get; set; }
        public string MSDV { get; set; }
        public string TenDV { get; set; }
        public string Khoa { get; set; }
        public string TenKhoa { get; set; }
        public string DienThoai { get; set; }
        public string DiaChi { get; set; }
        public string Email { get; set; }
        public string CTTC { get; set; }
        public string TLDG { get; set; }
        public CBTest(string id,string hoten, string nu, string ngaysinh, string coLuong, string ngach, string bac, string hsLg, string loai, string ngayTGCT, string chucVu, string hocVi
            , string msCD, string msTD, string huongDM, string maDV, string tenDV, string khoa, string tenKhoa, string dienThoai, string diaChi, string email, string cTTC, string tLDG)
        {
            this.ID = id;
            this.HoTen = hoten;
            this.Nu = nu;
            this.NgaySinh = ngaysinh;
            this.CoLuong = coLuong;
            this.Ngach = ngach;
            this.Bac = bac;
            this.HSLg = hsLg;
            this.Loai = loai;
            this.NgayTGCT = ngayTGCT;
            this.ChucVu = chucVu;
            this.HocVi = hocVi;
            this.MSCD = msCD;
            this.MSTD = msTD;
            this.HuongDM = huongDM;
            this.MSDV = maDV;
             this.TenDV = tenDV;
             this.Khoa = khoa;
             this.TenKhoa = tenKhoa;
             this.DienThoai = dienThoai;
             this.DiaChi = diaChi;
             this.Email = email;
             this.CTTC = cTTC;
             this.TLDG = tLDG;
        }
    }

    
}